package com.ruoyi.common.tools.enums;

import java.util.Calendar;

import com.ruoyi.api.dto.StatDateEnumDto;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum StatDateEnum {
	
	currDay,
	prevDay,
	currMonth ,
	prevMonth,
	currYear,
	prevYear
	;
	
	public static StatDateEnumDto getStatDateEnumDto(StatDateEnum dateEnum) {
		String year = null;
		String month = null;
		String day = null;
		
		Calendar calendar = Calendar.getInstance();
		
		switch (dateEnum) {
		case currDay:
			month = String.valueOf(calendar.get(Calendar.MONTH) + 1);
			day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
			break;
		case prevDay:
			calendar.add(Calendar.DAY_OF_MONTH , -1);
			month = String.valueOf(calendar.get(Calendar.MONTH) + 1);
			day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
			break;
		case currMonth:
			month = String.valueOf(calendar.get(Calendar.MONTH) + 1);
			break;
		case prevMonth:
			calendar.add(Calendar.MONTH , -1);
			month = String.valueOf(calendar.get(Calendar.MONTH) + 1);
			break;
		case currYear:
			break;
		case prevYear:
			calendar.add(Calendar.YEAR , -1);
			break;
		default:
			break;
		}
		
		year = String.valueOf(calendar.get(Calendar.YEAR));
		
		return new StatDateEnumDto(year , month, day);
	}
	
	public static void main(String [] args) {
		System.out.println(getStatDateEnumDto(StatDateEnum.currDay));
		System.out.println(getStatDateEnumDto(StatDateEnum.prevDay));
		System.out.println(getStatDateEnumDto(StatDateEnum.currMonth));
		System.out.println(getStatDateEnumDto(StatDateEnum.prevMonth));
		System.out.println(getStatDateEnumDto(StatDateEnum.currYear));
		System.out.println(getStatDateEnumDto(StatDateEnum.prevYear));
	}
}
